using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 返利收费 (满xx返xx/满xx减xx)
/// </summary>
public class CashReturn : CashSuper
{
    /// <summary>
    /// 返利条件
    /// </summary>
    private float moneyCondition = 0;

    /// <summary>
    /// 返利数量
    /// </summary>
    private float monetReturn = 0;


    public CashReturn(float moneyCondition, float monetReturn)
    {
        this.moneyCondition = moneyCondition;
        this.monetReturn = monetReturn;
    }

    /// <summary>
    /// 设置返利条件
    /// </summary>
    /// <param name="moneyCondition"></param>
    /// <param name="monetReturn"></param>
    public void SetCondition(float moneyCondition, float monetReturn)
    {
        this.moneyCondition = moneyCondition;
        this.monetReturn = monetReturn;
    }


    public override float AcceptCash(float money)
    {
        float result = money;

        //根据需要，计算具体的返利内容
        if (money >= this.moneyCondition)
        {
            result = money -   Mathf.Floor(money / moneyCondition) * monetReturn;
        }
        return result;
    }
}
